<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>My JSP 'showUser.jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

</head>
<script type="text/javascript"  src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<
<script type="text/javascript">
    function deleteById(id) {

        $.post( 'http://localhost:8080/spring2/user/deleteUser?id=' + id).done(function(data) {

            var rst = data.responseText;

            if (rst == '1') alert('删除成功！');
            else alert('删除失败'+ rst.toString());
        });

    }
</script>
<body>
<c:forEach items="${uList }" var="u">
    <form action="http://localhost:8080/spring2/user/updateUser" method="post">
        用户ID: <input type="text" value="${u.id}" id="id" name="id" readonly="readonly">
        用户名称：<input type="text" value="${u.name}" id="name" name="name">
        用户密码: <input type="text" value="${u.password}" id="password" name="password">
        用户年龄：<input type="text" value="${u.age}" id="age" name="age">
        <input type="submit" value="更新" >
    </form>
    <button onclick="deleteById(${u.id})">删除</button>
    <br/>
</c:forEach>
</body>
</html>
